home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 018a / amac41.zip / SM.QM < prev    next >
Text File  |  1991-08-26  |  22KB  |  470 lines

  1. *                              SM.QM  ver N                            8/26/91
  2. *                        Written by Tom Hogshead
  3. * ┌────────────────────────────── (Index) ─────────────────────────────┐
  4. * │
  5. * │ @(6)  Search from command line, load files w/search text,
  6. * │                    **** MUST use SM.BAT ****
  7. * │
  8. * │ (f4)  Finds search text in file after loading
  9. * │
  10. * │ (f5)  PrevFile
  11. * │
  12. * │ (f6)  NextFile
  13. * │
  14. * │ @(h)  Finds first word on cursor line marked in document below
  15. * │
  16. * │ (Description)
  17. * │ (Syntax)
  18. * │ (Mode)
  19. * │ (Required)
  20. * │ (Options) - MaxFind
  21. * │ (NOTE)
  22. * │ (Examples)
  23. * │ (Index) use with @h
  24. * │ (MaxFind) description
  25. * │ (PCED) synonymns to search from a file list
  26. * │ (Other) macros:
  27. * │ (ENVIRONMENT) Variables - See SRCHxx.QM for discussion             |K
  28. * │ (REQUIRED) PROGRAM FILES
  29. * │ (CAUTION) ***********
  30. * │ (Version) history
  31. * └────────────────────────────────────────────────────────────────────┘
  32.  
  33.  
  34. * (DESCRIPTION):
  35. *
  36. * SM.QM are QEdit macros to search files containing a search string using
  37. * MaxFind. Files are searched, found, and loaded for editing or viewing.
  38. * The search string, file names, and other input or search options may be
  39. * specified at the command line or entered at the option query prompt.
  40. * "Fuzzy", "and/or", and "sliding window" text searches can be done.
  41. *
  42. * To run, type "sm" <enter>, and answer the prompts. Press F4 to
  43. * view the search string in each file after finding. Alternatively,
  44. * parameters may be specified at the command line.
  45.  
  46. * 1) SYNTAX:                           SM.BAT %1 %2 %3
  47. *                                   ┌──────────┘  │  └───────────┐
  48. *              (Mode)              %1            %2             %3
  49. *                             Search Text     File Name       Option
  50. *          ----------------   -------------   ----------      -------
  51. *       a) Query              <------- all inputs at prompts ------->
  52. *       b) Partial Query      Search Text        [ ]            [ ]
  53. *       c) Partial Query      Search Text        [ ]          default
  54. *       d) Command line       Search Text     File Name       default
  55. *       e) All command line   Search Text     File Name         [ ]
  56. *
  57. *          where:    %1  - Search Text
  58. *                    %2  - File Name, wild cards OK
  59. *                    %3  - MAXFIND options entered without minus
  60. *                    [ ] - entered at query prompt
  61. * 2) Requires MAXFIND MF.EXE and INPUT.COM
  62. * 3) File Name wild cards OK.
  63. * 4) MAXFIND options can be input at option prompt or %3, default option "ltn"
  64. * 5) Set environment variable OPT=off to bypass MAXFIND option query prompt
  65. *
  66.  
  67. * MAXFIND (OPTIONS):
  68. *
  69. *  MaxFind. Version 2.3   Copyright 1988,90 by Stan Peters
  70. *            Shareware, $15.       Box 2028, Fairfield, Iowa 94306
  71. *   Usage:  mf  [-options] string  [string].... filename [-options]
  72. *         Filename may contain ? and *, it may have a path prefix
  73. *         You may have 1 to 15 strings.
  74. *         A tilde (~) in a string matches any character.
  75. *         Options must start with a '- ', they may be first and/or last.
  76. *     Searching options:
  77. *        a - 'and', all must be present.  f - "fuzzy", approximate spelling.
  78. *        c - case sensitive search.       w - match only if a word.
  79. *        d - Span entire document, if necessary.
  80. *     Output options:
  81. *        l - show line numbers.      (*)   t - to screen and > file.    (*)
  82. *        m - stop after first match. (*)   u - Unix (grep) style output.(*)
  83. *        n - no pause each 24 lines. (*)
  84. *     Input options:
  85. *        b - also search binary files.    s - also include subdirectorys
  86. *        h - strip hi (8) bits.
  87. *     AND searches using "sliding windows":
  88. *        2 - 15  Window size (number of lines) for searching and displaying
  89. *
  90. *         afcwdbsh/ - OK with SM
  91. *
  92. *  A  /  indicates an OR within an AND, use  //  to find  / .
  93. *     Example:  Find Tom or Bob Jones from Texas in my address file
  94. *     Enter:   "mf  tom/bob jones texas  address.fil  -a4"
  95. *
  96. *     (*) - do not use with sm.bat, "ntl" are default options with sm.bat
  97.  
  98. * (NOTE):
  99. *     - @6 must be the first macro in this file to be used with sm.bat.
  100. *     - To use this macro in any directory, change /Esm.mac and
  101. *       /Lsm.mac in sm.bat to the location of sm.mac, eg change to
  102. *       /Ee:\up\sm.mac.
  103. *     - Enter other search or input options as %3 or at the option,
  104. *       prompt, eg "c" for case sensitive search without the minus.
  105. *     - Search is case insensitive unless option "c" is specified.
  106. *     - If no files are found containing the search text, a message
  107. *       "No text found" is displayed.
  108. *     - Macro will stop before completion if any line containing the
  109. *       search text also contains "g>". Macro cannot search for "g>".
  110. *     - This macro can be quite "noisy" if beeps are set on with
  111. *       QCONFIG, especially if there are many lines containing
  112. *       search text. We use "Find" to check each line of the output
  113. *       to determine whether it is a file name or found text. File
  114. *       names are not quite as "noisy". Testing this macro has forced
  115. *       me to set QEdit beeps "off"!
  116. *     - A minimum of of 55 bytes free environment space is needed to
  117. *       search for a 10 character string with 12 character file spec
  118. *       and 1 character option. I suggest you have at least a 100
  119. *       bytes free to be safe. Since the free environment space is
  120. *       considerably reduced when "shelling to DOS", sm.bat may not
  121. *       work properly when "shelled" from another program.
  122. *     - MaxFind writes to disk at least once for every file it
  123. *       searches. Therefore, for faster macro operation, replace c:\
  124. *       in sm.bat and sm.qm with your ram drive.
  125.  
  126. * (EXAMPLES):
  127.  
  128. *     a)  Example:  Load all files with extension "bat" or "tst"
  129. *                   containing "aaa"  and "bbb" in each file.
  130. *             (Must be run from input mode because of %1 %2 %3 defs.)
  131. *         Enter:    "sm" <enter>, and at the query prompts enter...
  132. *                         Search text   =aaa bbb
  133. *                         File name(s)  =*.??t
  134. *                         Option(s)     =
  135. *
  136. *     b)  Example:  Load all files with extension "tst" containing "ccc"
  137. *         Enter:   "sm ccc *.tst" <enter>
  138.  
  139. *     c)  Example:  Load all files containing "ddd" and "eee" only
  140. *                   within a 2 line window in each file, with extension
  141. *                   "tst".
  142. *                (Must be run from input mode because of %1 %2 %3 defs.)
  143. *         Enter:    "sm" <enter>, and at the query prompts enter...
  144. *                         Search text   =ddd eee
  145. *                         File name(s)  =*.tst
  146. *                         Option(s)     =a2
  147. *                   (sm.tst is included to test above examples)
  148.  
  149. * (INDEX) USE:
  150. * To locate a macro or item in this file, press @h, place the cursor
  151. * line on the desired item in the Index above, and press <enter>.
  152. * See BOOKxx.QM for more details.
  153.  
  154. * (MAXFIND) DESCRIPTION (extracted from MaxFind.doc):
  155. *      Basically, this program works much like other FIND programs
  156. *      that you may have used.  Enter the program name at the DOS
  157. *      prompt, followed by a string, and then the file name.  But
  158. *      there are several powerful advantages:
  159. *        - Search for up to 15 strings on one pass over the file with
  160. *          little performance penalty.
  161. *        - Combination and/or searches are definable in an easy to use way.
  162. *        - Will search subdirectories or the entire disk.
  163. *        - Has a "fuzzy" search, spelling need not be exact.
  164. *        - A help screen is available, enter  mf  <ENTER> at the DOS prompt.
  165. *        - It works quickly!  Now, with Version 2.3, simple searches on
  166. *          my 8 mHz AT disk scan at 100 thousand bytes per second.
  167. *          It moves at 70k bytes per second for quite complex searches.
  168. *        - A scan window size option for matching and display.  Great for
  169. *          Name and Address lists and for finding phrases or quotes that
  170. *          span more than one line.
  171. *        - It is useful on word processors documents and data bases that
  172. *          keep their data in an ASCII format.
  173.  
  174. *      The overall effect of this combination of features is a text
  175. *      search program, that in the words of PC magazine (1/31/89),
  176. *      "..holds its own with the best commercial programs."
  177. *
  178. *      Since then, Lotus has introduced Magellan, a shell with text
  179. *      search.  This $179 program will take two megabytes out of a
  180. *      20meg hard disk for an index to the entire disk.  I have
  181. *      looked at it briefly and I'm impressed.  Fast searches and
  182. *      "launching" into the appropriate program.  But I feel that
  183. *      anyone who needs that, should  ALSO  have MaxFind.  Because,
  184. *      after all, finding "lost" information is not an easy job with
  185. *      ANY program.  MaxFind is the preferred tool for these cases:
  186. *        - Names and words with unknown spelling.
  187. *        - Longer documents.  With my limited exposure to Magellan,
  188. *            it appears that it finds FILES very quickly, but its up
  189. *            to you to scroll through the document.  MaxFind will
  190. *            show you up to 24 found word(s), in context, on one
  191. *            screen.
  192. *        - Finding a quote.  Magellan doesn't index about 150 common
  193. *          words.  If many of these are in the quote - problems.
  194. *        - It won't fit on a floppy based laptop.
  195.  
  196. *----------------------------------------------------------------------
  197. * (PCED) synonymns to search from a file list
  198. *
  199. * MaxFind does not have the option of searching from a file list.
  200. * However PCED by Chris Dunford with the following synonyms using the
  201. * "@@file list" option will search from the file list "sm.lst".
  202. *
  203. * rem PCED synonyms for MaxFind Search, Syntax: SMC1 [search text]
  204. *
  205. *     SYN smc1     'cef^cancel &A^delc^mfc &A^qec^cen'
  206. *     SYN cancel   'if "&A" == "" CED CANCEL notxt'
  207. *     SYN notxt    'echo No search text, Syntax: SMC1 [search text]^cen'
  208. *     SYN cef      'CED ECHO OFF^echo off'
  209. *     SYN delc     'if exist c:\! del c:\!'
  210. *     SYN cen      'echo on^CED ECHO ON'
  211. *     SYN mfc      'mf.exe -ntl &A @@sm.lst>>c:\!'
  212. *     SYN qec      'q.exe c:\! /Esm.mac /Lsm.mac'
  213. * rem SYN mfc      'mf.exe -ntl &A @@e:\up\sm.lst>>c:\!'
  214. * rem SYN qec      'q.exe c:\! /Ee:\up\sm.mac /Le:\up\sm.mac'
  215.  
  216. * NOTE: Change "e:\up\" to the directory where sm.mac and sm.lst reside.
  217. * "REM" lines are my setup.
  218. *
  219. * You must have PCED v2.00 or later with the Filelist progam FL.EXE
  220. * loaded. These synonyms are in sm.sym and can be loaded with SM_SYN.bat
  221.  
  222. * File list sm.lst is only one line "*.tst" for testing. To test,
  223. * type "smc1 aaa" <enter> after loading these synonyms. You should
  224. * see the following file loaded after the macro completes running:
  225. *
  226. * +- Searching> SM.TST
  227. * 3:aaa bbb ccc ddd eee fff ggg hhh iii jjj jjj lll mmm nnn ooo
  228.  
  229. * Here's the file list I keep in e:\up\sm.lst:
  230. *
  231. *                 *.qm
  232. *                 *.ql
  233. *                 *.inf
  234. *                 *.bat
  235. *                 *.lst
  236. *                 *.me
  237. *                 *.doc
  238. *                 *.syn
  239. *                 *.new
  240. *                 *.tst
  241. *                 e:\syn\sa.syn
  242. *                 u:\sr?.bat
  243.  
  244. * (OTHER) MACROS:
  245. *
  246. * See SRCxxx.QM in AMACxx.Zip for search and search/replace macros using
  247. * Chris Dunford's excellent FGREP.COM.com.
  248.  
  249.  
  250. * ******* (CAUTION) ***********
  251. *
  252. * Letters "S~~" and "R~~" must NOT occur in any other Dos environment
  253. * variable name or value.
  254. *
  255.  
  256. * (ENVIRONMENT) Variables - See SRCHxx.QM for discussion
  257.  
  258. * (REQUIRED) PROGRAM FILES
  259. *
  260. * You──MUST──have the exectable program files in AMAC-PRG.ZIP to run
  261. * some of these macros. AMAC-PRG.ZIP can be found on the following BBS's:
  262. *
  263. *                                 SemWare
  264. *                                 Exec-PC
  265. *
  266. * It can not be found on CompuServe since many of the programs are
  267. * Copyrighted. All program files are ShareWare, and inclusion in
  268. * AMAC-PRG.ZIP is not prohibited in their documentation.
  269. *
  270. * MAXFND23.ZIP and INPUT.ZIP are the only files necessary to run SM.BAT.
  271. *
  272. * INPUT can be found on Exec-PC as INPUT.ZIP. MAXFIND v2.3 can be found
  273. * on CompuServe IBMSYS Lib 3 as MAXFND.ZIP and on EXec-PC as
  274. * MAXFND23.ZIP
  275. *
  276. * AMAC-PRG.ZIP contains:
  277. * ----------------------
  278. * Name          Length    Method     SF   Size now  Mod Date
  279. * ============  ========  ========  ====  ========  =========
  280. * INPUT.ZIP         3097   Stored     0       3097  07 May 86
  281. * MAXFND23.ZIP     24247   Stored     0      24247  26 Apr 90
  282. * RJ.ZIP            9965   Stored     0       9965  01 Dec 90
  283. * FGREP172.ZIP     12513   Stored     0      12513  19 May 90
  284. * DX211.ZIP       100895   Stored     0     100895  17 Mar 89
  285. * AMAC-PRG.INF      3138  Imploded   67       1014  23 Apr 91
  286. * ============  ========  ========  ====  ========  =========
  287. * *total     6    153855  ZIP 1.10    0%    152329  23 Apr 91
  288. *
  289. * I thank the authors for these excellent programs.
  290.  
  291. * 
  292. * ----------------------------------------------------------------------
  293. * @(6) - Srch ONLY from command line, loads files w/sm.bat, no replace   *
  294. * -------------------- uses MaxFind mf.exe ----------------------------- *
  295. **** MUST BE THE FIRST MACRO IN THIS FILE TO BE USED WITH SM.BAT ****
  296. *
  297. @6 macrobegin
  298.         altwordset                      * For all file names
  299.         begfile                         * Just in case!
  300. * ----------------- delete MaxFind Copyright header -----------------*
  301.  header:                                *
  302.         find "xfind C" return return    * Find MaxFind header
  303.         jfalse end_header:              *
  304.         delline                         * Delete it until no more
  305.         jump header:                    *
  306.  end_header:                            *
  307. * --------- delete "Hex file skipped" message and file name ---------*
  308.         begfile                         * Back to tof
  309.  hex:                                   *
  310.         find "Hex file s" return return * Find "Hex file skipped" msg
  311.         jfalse end_hex:                 *
  312.         delline                         * Delete it until no more
  313.         cursorup                        * Move up to hex name
  314.         delline                         * Delete it
  315.         jump hex:                       * And do until done
  316.  end_hex:                               *
  317.         begfile                         * Back to tof
  318. * ------------------ delete file names with no text ------------------*
  319.  cleanup:                               *
  320.         begline                         * Position for find
  321.         unmarkblock                     *
  322.         markline markline               * Mark line to check if name
  323.         find "g>" return "L"  return    * Check if name
  324.         jtrue name:                     * If name, check if next line
  325.                                         * is also name
  326.         cursordown                      *ELSE move down to next line
  327.         jfalse end_cleanup:              * If can't move down, at eof
  328.         jump cleanup                    * Check this line if name
  329.  name:
  330.         cursordown                      * Is a file, move down to next
  331.                                         * line
  332.         jfalse delete:                  * If can't move down, at eof
  333.                                         * and it's a name, go delete it
  334.         cursorright                     *ELSE put cursor on >
  335.         unmarkblock                     *
  336.         markcolumn                      * Begin mark
  337.         cursorleft                      * Move left one space
  338.         markcolumn                      * Mark column to check for "g>"
  339.         cursorleft                      * Move to "n" in "Searching"
  340.         find "g>" return "L"  return    * Is line a name?
  341.         jfalse cleanup:                 * If not a name, go to cleanup
  342.         cursorup                        *ELSE must be text, move back
  343.                                         * up to where we were
  344.         jfalse end_cleanup:             * If can't move up, at tof
  345.         delline                         *ELSE Delete name with no text
  346.         jump cleanup:                   *
  347.  delete:                                *
  348.         delline                         * Delete last line if name
  349.  end_cleanup:                           *
  350. * -------------------- load file names with text --------------------*
  351.         endfile                         * Start to load at eof
  352.  load:                                  *
  353.         begline                         * Position for find
  354.         find "g>" return "B"  return    * Find line with file name
  355.         jfalse text:                    * No more file names? Move up
  356.         wordright *wordright wordright  * Move to file name
  357.         unmarkblock                     * Clear last mark
  358.         markcolumn                      * And begin mark
  359.         endline                         * Get all name in block
  360.         copy                            * Copy file name to scrap
  361.         EditFile                        * Get ready to load
  362.         CurrentFilename " "             * To force return *here*
  363.         Paste Return                    * Paste file name & do it!
  364.  text:
  365.         cursorup                        * Go to next line
  366.         jfalse end_load:                * No more file names? End load
  367.         jump load:                      *ELSE more files to load
  368.  end_load:                              *
  369. * --------------------- "No found text" message ---------------------*
  370.         cursordown cursorup             * Test if any search text found
  371.         jtrue find_set:                 * If found, move on
  372.         "No found text "                *ELSE no find, display this
  373.         jump end:                       * End macro if no found text
  374.  find_set:                              *
  375. * -------------------- initialize find for search --------------------*
  376.         editfile "c:\$" return          * Load tempfile
  377.         find  "S~~" return return      ** Find S~~ in SET output
  378.         find "=" return return          * Move to =
  379.         cursorright                     * Move first character
  380.         markcharacter                   * Mark it
  381.         endline                         * Move to end of text
  382.         copy                            * Copy search text to scrap
  383.         killfile quit                   * Kill/quit temp for next time
  384.         Find paste return Escape        * Initialize find for F4
  385. * ------------------------------ reset ------------------------------*
  386.  end: defaultwordset                    * Reset
  387. *
  388. * 233 bytes Wed  04-17-1991  16:35:04
  389. * 216 bytes Wed  04-24-1991  14:18:01 moved DOS "set>c:$" to SM.BAT
  390. *                                     replace R~~ with S~~
  391. * 221 bytes Tue  04-30-1991  22:28:02 changed initialize find routine
  392.  
  393.  
  394. * 
  395. * ----------------------------------------------------------------------
  396. * (f4) Finds search text in file after loading
  397. * ----------------------------------------------------------------------
  398. *
  399. f4 repeatfind
  400.  
  401. * 
  402. * ----------------------------------------------------------------------
  403. * (f5) prevfile
  404. * ----------------------------------------------------------------------
  405. *
  406. f5 prevfile
  407.  
  408. * 
  409. * ----------------------------------------------------------------------
  410. * (f6) nextfile
  411. * ----------------------------------------------------------------------
  412. *
  413. f6 nextfile
  414.  
  415. * 
  416. * ----------------------------------------------------------------------
  417. * @(h) Finds first word on cursor line marked in document below
  418. * ----------------------------------------------------------------------
  419. *
  420. * Press @ and h at the same time. Cursor down to desired line in Index.
  421. * Press <enter> to locate the desired item from the Index. See
  422. * Bookxx.Qm in AMACxx.Zip for more discussion.
  423. *
  424. @h macrobegin
  425.         begfile
  426.         unmarkblock
  427.         markline markline
  428.         pause
  429.         wordright
  430.         markword
  431.         copy
  432.         endpara
  433.         find "(" paste ")"  return return
  434.         begline
  435. *
  436. * 22 bytes Tue  04-09-1991  16:23:53
  437.  
  438. * (Version) history:
  439. *   A   -   Initial
  440. *   B   -   Modified "No found text" message handling.
  441. *       -   Wrong copy of sm.bat in AMAC-B.ZIP -corrected.
  442. *   C   -   Changed PCED synonym to show directory/path.
  443. *       -   Corrected @6 to handle "window" searches and initialize
  444. *           find for F4 correctly.
  445. *       -   Changed examples.
  446. *       -   Left sm.lst out of amac-c.zip, added it.
  447. *   D   -   Changed PCED synonyms to use "CED CANCEL".
  448. *   E   -   Changed find initialize FGS to FGR to find replacement
  449. *           text with F4 IN @6.
  450. *   F   -   Shortened SM.BAT by removing "Mode" output.
  451. *       -   Removed DelLine and UnMarkBlock from @6
  452. *   G   -   Moved DOS "set>c:$" to SM.BAT
  453. *       -   Corrected @6 find initialize FGR to FGS to find search
  454. *           text with F4 in @6.
  455. *   H   -   Changed FGR to R~~
  456. *       -   Changed FGS to S~~
  457. *       -   Changed initialize find routine in @6
  458. *   K   -   Added reference to environment variables.
  459. *   L   -   Minor documentation changes.
  460. *   M   -   Changed SRCHxx version from 2.9 to 3.0.                     8/6/91
  461. *   N   -   Changed SM-SYN.BAT name to SM_SYN.BAT.                     8/26/91
  462. *
  463. *
  464. *
  465. *
  466. *
  467. *
  468. *
  469. *
  470.